/*
 * =====================================================================================
 *
 *       Filename:  main.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  02/01/2021 06:34:34 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  jianxi sun (jianxi), ycsunjane@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */

#ifndef __MINA_H__
#define __MINA_H__

#include <sys/types.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <unistd.h>

#include "log.h"
#include "cmdline.h"
#include "common.h"
#include "config.h"
#include "list.h"
#include "buffer.h"
#include "serial.h"

#define SPEED 		(9600)
#define BITS 		(8)
#define EVENT 		'N'
#define STOP 		(1) 
#define BUFSIZE 	(512)

struct server_listen {
	struct ev_loop *loop;
	int listenfd;
	ev_io io;
};

struct client_t {
	struct ev_loop *loop;
	int	fd;
	buffer_t *rxbuf;
	struct cli_ctx *recv_ctx;
	struct 	sockaddr_in cliaddr;
};

struct cli_ctx {
	ev_io io;
	struct client_t *cli;
};

#endif
